package jobs.slow_project_byte_summary;


import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

public class SlowProjectByteSummariser extends Configured implements Tool {

	

	
	@Override
	public int run(String[] args) throws Exception {
		
		
		
		Job job = new Job();
		job.setMapperClass(SlowProjectByteSummariserMap.class);
        job.setReducerClass(SlowProjectByteSummariserReduce.class);
        job.setJarByClass(SlowProjectByteSummariserMap.class);
        
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);
        
        job.setJobName(args[0]);
        
        job.getConfiguration().setLong("delay_ms", Long.valueOf(args[3]));
        job.getConfiguration().setInt("delay_ns", Integer.valueOf(args[4]));
        
        FileInputFormat.setInputPaths(job, new Path(args[1]));
        FileOutputFormat.setOutputPath(job, new Path(args[2] + "-" + args[0] + "-" + System.currentTimeMillis()));

        job.submit();

		return 0;
	}

	

}
